package com.example.testeviews;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnFocusChangeListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.EditText;

public class TextViews extends Activity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.texts);

		String[] meses = getResources().getStringArray(R.array.nomes);
		AutoCompleteTextView tv = (AutoCompleteTextView) findViewById(R.id.autoCompleteText);
		tv.setAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_dropdown_item_1line, meses));
		tv.setOnFocusChangeListener(new OnFocusChangeListener() {
			@Override
			public void onFocusChange(View v, boolean hasFocus) {

				EditText et = (EditText) findViewById(R.id.threasholdText);
				if (hasFocus) {
					((AutoCompleteTextView) v).setThreshold(Integer.parseInt(et
							.getText().toString()));
				}

			}
		});

	}
}
